Sum of all counts in a collectionsΒΆ
Sum of all counts in a collections
import collections
L = [2, 2, 4, 6, 6, 8, 6, 10, 4]
print(sum(collections.Counter(L).values()))
Output:
9
import collections
L = [2, 2, 4, 6, 6, 8, 6, 10, 4]
print(sum(collections.Counter(L).values()))
Output:
9